import { Controller, Get, Post, Body, Param, Delete } from '@nestjs/common';
import { ApiExcludeEndpoint, ApiTags } from '@nestjs/swagger';

import { FoodService } from './food.service';
import { CreateFoodReqDto, FoodListReqDto, FoodResDto } from './dto/food.dto';

import { JwtPass } from '@/core/decorator';

@ApiTags('小程序/食物')
@Controller('app/food')
export class FoodController {
  constructor(private readonly foodService: FoodService) {}

  /**
   * 食物创建(不用)
   */
  @Post()
  @JwtPass()
  async createFood(@Body() food: CreateFoodReqDto) {
    await this.foodService.create(food);
  }

  /**
   * 食物列表
   */
  @Get()
  foodList(@Body() params: FoodListReqDto): Promise<FoodResDto[]> {
    return this.foodService.findAll(params);
  }

  /**
   * 食物详情
   */
  @Get(':id')
  foodDetail(@Param('foodId') foodId: number): Promise<FoodResDto> {
    return this.foodService.findOne(foodId);
  }

  /**
   * 食物更新
   */
  // @Put(':foodId')
  // update(
  //   @Param('foodId') foodId: string,
  //   @Body() updateFoodDto: UpdateFoodDto,
  // ) {
  //   return this.foodService.update(foodId, updateFoodDto);
  // }

  /**
   * 食物删除
   */
  @ApiExcludeEndpoint()
  @Delete(':foodId')
  async removeFood(@Param('foodId') foodId: number) {
    await this.foodService.fakeRemove(foodId);
  }
}
